package com.shushan.mixedexam.strangewords.bean;

import com.android.net.bean.NetBaseBean;
import com.shushan.base.Constants;
import com.shushan.mixedexam.bean.ExerciseOptionBean;
import com.shushan.mixedexam.bean.ExerciseVideoBean;
import com.shushan.mixedexam.bean.NewTypeOptionBean;
import com.shushan.pages.bean.PaperInfoBean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: StrangeWordsExerciseBean
 * @Desciption: //生字练习习题bean
 * @author: zhangshihao
 * @date: 2018-07-24
 */
public class StrangeWordsExerciseBean extends NetBaseBean {

    public int outline_detail_id;
    public int id;
    public String questions;
    public String voice;
    public String voice_time;
    public int type;//生字题型 1、题目属于文字型 2、题目属于音频
    public String exercises_type;//NEWWORD代表生字题型
    public int subject_id;
    public int outline_id;
    public String new_word;
    public String exercises_content;
    public int score;
    public int child_collect;
    public int my_answer_id;

    private List<NewTypeOptionBean> optionBeans = new ArrayList<>();
    private List<ExerciseVideoBean> videoBeans = new ArrayList<>();

    @Override
    public void initByJson(JSONObject jsonObject) throws JSONException {
        if(jsonObject == null){
            return;
        }
        outline_detail_id = jsonObject.optInt("outline_detail_id",0);
        id = jsonObject.optInt("id",0);
        questions = jsonObject.optString("questions","");
        voice = jsonObject.optString("voice","");
        voice_time = jsonObject.optString("voice_time","");
        type = jsonObject.optInt("type",0);
        exercises_type = jsonObject.optString("exercises_type","");
        subject_id = jsonObject.optInt("subject_id",0);
        outline_id = jsonObject.optInt("outline_id",0);
        new_word = jsonObject.optString("new_word","");
        exercises_content = jsonObject.optString("exercises_content","");
        score = jsonObject.optInt("score",0);
        child_collect = jsonObject.optInt("child_collect",0);
        my_answer_id = jsonObject.optInt("my_answer_id",0);

        JSONArray optionArr = jsonObject.optJSONArray("exercise_option");
        if(optionArr != null && optionArr.length() > 0){
            for(int i=0;i<optionArr.length();i++){
                JSONObject jobj = optionArr.optJSONObject(i);
                NewTypeOptionBean optionBean = new NewTypeOptionBean();
                optionBean.initByJson(jobj);
                optionBeans.add(optionBean);
            }
        }

        JSONArray videoArr = jsonObject.optJSONArray("video");
        if(videoArr != null && videoArr.length() > 0){
            for(int i=0;i<videoArr.length();i++){
                JSONObject jobj = videoArr.optJSONObject(i);
                ExerciseVideoBean videoBean = new ExerciseVideoBean();
                videoBean.initByJson(jobj);
                videoBeans.add(videoBean);
            }
        }

    }

    public List<NewTypeOptionBean> getOptionBeans() {
        return optionBeans;
    }

    public List<ExerciseVideoBean> getVideoBeans() {
        return videoBeans;
    }
}
